package model

import business.Attackable
import business.Blockable
import business.Destoryable
import business.Sufferable
import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter

/**
 * 砖墙
 *
 * 阻塞的能力
 * 接受攻击的能力
 * 销毁的能力
 * */
class Wall(override var x: Int, override var y: Int) :Blockable,Sufferable,Destoryable {

    override val width: Int=GameConfig.SMALL_BLOCK_WIDTH
    override val height: Int=GameConfig.SMALL_BLOCK_WIDTH

    override var pool: Int=2

    override fun draw() {
        Painter.drawImage("img/wall_small.gif",x,y)
    }

    override fun notifySuffer(attack: Attackable):ArrayList<IView> {
        var list=ArrayList<IView>()
//        list.add(Blast(x,y))

        /** 掉血*/
        pool-=attack.power

        attack as Bullet
        if(attack.ower is MyTank){ //我方坦克攻擊墻是播放聲音
            //播放子弹打墙的声音
            Composer.play("snd/hit.wav")
        }

        return list
    }

    override fun isDestory(): Boolean {
//        println("Wall isDestroyed pool=$pool")
        return pool<=0
    }
}